package com.bruce.exec.utils;

/**
 * @author xin.ding
 * @date 2021/4/16 15:52
 */
public class Platform {

    /**
     * 进程处理类单例
     */
    private static volatile  ProcessHandler processHandler;

    /**
     * 获取进程处理对象
     * @return obj
     */
    public static ProcessHandler getProcessHandler() {
        if (processHandler == null) {
            synchronized (Platform.class) {
                if (processHandler == null) {
                    processHandler = isWindows() ? new WinProcess() : new UnixProcess();
                }
            }
        }
        return processHandler;
    }

    /**
     * 是否windows系统
     */
    public static boolean isWindows() {
        String osName = System.getProperties().getProperty("os.name");
        return osName.toLowerCase().startsWith("windows");
    }

}

